program drop _all

/* THIS PROGRAM IMPLEMENTS TOBIT REGRESSIONS IN TABLE 6 (cols. 1-2); IC-STATA ver. 10.1 
   NOTE: All the source and results files are saved at single directory: C:\RESTAT\   */


program define GROWTH
clear all
set more off
set memory 80m
set matsize 800
use C:\RESTAT\data1.dta, replace
log using C:\RESTAT\Tab6_tobit.log, replace   

                       
                       tsset firm year                      
                       sort primaryu


/* MERGE DATA with HIGH/LOW_FDI INDICATORS */
                      merge primaryu using C:\RESTAT\FDI_CNB.dta

                      display" DROP 11 INDUST WITHOUT FOREIGN PRESENCE"
                      drop if low_fdi==.

#delimit ;            




/* RESTRICT SAMPLE TO HIGH FDI (there is 65 high and 65 low-FDI indust.) */
                   
                   display" KEEP high_fdi";
                   keep if high_fdi==1; 


/* KEEP ONLY OBS W/ NON-MISSING REGRESSORS */
                   
                    keep if growth~=. & FG~=. & ageT~=. & sales~=. & AS~=. & ES~=. & FORdirect~=. &
                          intang~=. & ESgap~=. & gap~=. & solvency~=. ;

/* CREATE DUMMY=1 WHENEVER DOM ENTRY RATE>0 (ANALOGICALLY WITH FORentry var (=STATIC) */
                   

           /* gen OTHER_ENTRANTS1 */
                   display" GENERATE OTHER_ENTRANTS1 BY SUBTRACTING 1 IF THE FIRM IS OF AGE=1";
                   gen OTHER_ENTRANTS1=ENTRANTS1;
                   replace OTHER_ENTRANTS1=ENTRANTS1-1 if age==1; 
                   replace OTHER_ENTRANTS1=0 if OTHER_ENTRANTS1<0;
                

          /* gen dummy for DOMENTRY */
                    gen DOMENTRY=1 if  OTHER_ENTRANTS1>0;
                    replace DOMENTRY=0 if OTHER_ENTRANTS1==0;
                                                    
             

          /* gen firm level means */
                   
                    sort firm ;
                    by firm: egen avsales=mean(sales);
                    by firm: egen avsales2=mean(sales2);
                    by firm: egen avESgap=mean(ESgap);
                    by firm: egen avFG=mean(FG);        
                    by firm: egen avageT=mean(ageT);
                    by firm: egen avageT2=mean(ageT2);
                    by firm: egen avAS=mean(AS);
                    by firm: egen avES=mean(ES);
                    by firm: egen avFORdirect=mean(FORdirect);
                    by firm: egen avintang=mean(intang);
                    by firm: egen avgap=mean(gap);
                    by firm: egen avsolvency=mean(solvency);
                    
                 
                     
                    tsset firm year ;
                 

          

/* Note: drop 1 regional dummy from the full set, to avoid multicollinearity */

/* ************************************ TOBIT Tab. 6 (col.1) - industries w/ HIGH FDI stock ***************************************************************** */
 
                   xi:tobit growth FG STATIC DOMENTRY ageT ageT2 sales sales2 AS ES FORdirect intang gap ESgap 
                                    D89 solvency year94-year00 i.primaryu*trend reg1-reg7                                                                     
                                    konkurz liquidate both OUT_BR 
                                    avFG avageT avageT2 avsales avsales2 avAS avES avFORdirect avintang 
                                    avgap avESgap avsolvency,ll(-1);







/* ******************* REPEAT THE SAME STEPS BUT NOW RESTRICT THE SAMPLE FOR INDUST low_fdi=1 ******************** */

  clear;
  use C:\RESTAT\data1.dta, replace;
                       
                       tsset firm year ;                     
                       sort primaryu;


/* MERGE DATA with HIGH/LOW_FDI INDICATORS */
                      merge primaryu using C:\RESTAT\FDI_CNB.dta;
                      

                      display" DROP 11 INDUST WITHOUT FOREIGN PRESENCE";
                      drop if low_fdi==. ;  


/* RESTRICT SAMPLE TO LOW FDI -- there are 65 low-FDI indust */
                   
                   display" KEEP low_fdi";
                   keep if low_fdi==1; 



/* KEEP ONLY OBS W/ NON-MISSING REGRESSORS */
                   
                    keep if growth~=. & FG~=. & ageT~=. & sales~=. & AS~=. & ES~=. & FORdirect~=. &
                          intang~=. & ESgap~=. & gap~=. & solvency~=. ;

/* CREATE DUMMY=1 WHENEVER DOM ENTRY RATE>0 (ANALOGICALLY WITH FORentry var (=STATIC) */
                   

           /* gen OTHER_ENTRANTS1 */
                   display" GENERATE OTHER_ENTRANTS1 BY SUBTRACTING 1 IF THE FIRM IS OF AGE=1";
                   gen OTHER_ENTRANTS1=ENTRANTS1;
                   replace OTHER_ENTRANTS1=ENTRANTS1-1 if age==1; 
                   replace OTHER_ENTRANTS1=0 if OTHER_ENTRANTS1<0;
                

          /* gen dummy for DOMENTRY */
                    gen DOMENTRY=1 if  OTHER_ENTRANTS1>0;
                    replace DOMENTRY=0 if OTHER_ENTRANTS1==0;
                                                    
             

          /* gen firm level means */
                   
                    sort firm ;
                    by firm: egen avsales=mean(sales);
                    by firm: egen avsales2=mean(sales2);
                    by firm: egen avESgap=mean(ESgap);
                    by firm: egen avFG=mean(FG);        
                    by firm: egen avageT=mean(ageT);
                    by firm: egen avageT2=mean(ageT2);
                    by firm: egen avAS=mean(AS);
                    by firm: egen avES=mean(ES);
                    by firm: egen avFORdirect=mean(FORdirect);
                    by firm: egen avintang=mean(intang);
                    by firm: egen avgap=mean(gap);
                    by firm: egen avsolvency=mean(solvency);
                    
                 
                     
                    tsset firm year ;
                 

          

/* Note: drop 1 regional dummy from the full set, to avoid multicollinearity */

/* ************************************ TOBIT Tab. 6 (col.2) - industries w/ LOW FDI stock ***************************************************************** */
 
                   xi:tobit growth FG STATIC DOMENTRY ageT ageT2 sales sales2 AS ES FORdirect intang gap ESgap 
                                    D89 solvency year94-year00 i.primaryu*trend reg1-reg7                                                                     
                                    konkurz liquidate both OUT_BR 
                                    avFG avageT avageT2 avsales avsales2 avAS avES avFORdirect avintang 
                                    avgap avESgap avsolvency,ll(-1);



          

#delimit cr
log close
end
